% File: test_channel_ir.m
% -----------------------
% This script tests channel impulse response from stdchan.m

close all
clear all

Ts = 1/(50e6); fd = 0.001;
[chan chanprofile] = stdchan(Ts, fd, 'hiperlan2A');
chan.NormalizePathGains = 1;
chan.StoreHistory = 1;
chan.StorePathGains = 1;
h_tmp = filter(chan, [1,zeros(1,256)]);
figure();plot(chan);

pdp         = chanprofile.AvgPathGaindB;
ds          = chanprofile.PathDelays;
pdp_ls      = 10.^(pdp/10);
ds_mean     = sum(ds.*pdp_ls)/sum(pdp_ls);
ds_rms      = sqrt(sum((ds-ds_mean).^2.*pdp_ls)/sum(pdp_ls));
ds_rms_norm = ds_rms/Ts;

tao_norm = chan.PathDelays/Ts;
n = (-4:1:28-4);
h = chan.PathGains(1,:)*sinc(repmat(tao_norm.',[1,length(n)])-repmat(n,[length(tao_norm),1]));
figure();stem(n,abs(h));

% End of script